<?php
declare (strict_types = 1);

namespace app\index\controller;

// use think\Request;
use think\facade\Db;
use think\facade\Cache;
use think\facade\Request;
use think\facade\Config;

class Booking{
    //获取列表
    public function getListByopenId(){
        if(Request::isPost()){
            $openId=input('param.openId','');
            $accountId=input('param.accountId',0);
            $page=input('param.page',1);
            $size=input('param.size',10);
            $data=Db::table('activity_booking ab')
            ->field('ab.mobile,ab.true_name,ab.nickname,ab.booking_date,ab.accompany,ab.remark')
            ->field('a.title')
            ->join('activity a','ab.activity_id=a.id')
            ->where(['ab.openid'=>$openId])
            ->order('ab.create_at desc')
            ->paginate([
                'list_rows' => $size,
                'page'      => $page
            ]);
            $total=$data->total();
            $data=$data->items();
            $page_count=ceil($total/$size);
            return json(['code'=>200,'message'=>'获取成功','success'=>true,'result'=>['list'=>$data,'total'=>$total,'page'=>['current'=>$page,'size'=>$size,'total'=>$page_count]]]);
        }
    }    
}